/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.session;

import edu.fpt.entity.Room;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author TuanAnh
 */
@Stateless
public class RoomFacade extends AbstractFacade<Room> implements RoomFacadeLocal {

    @PersistenceContext(unitName = "ProjectManagementHotel-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RoomFacade() {
        super(Room.class);
    }

    @Override
    public int getPrice(String id) {
        int c = 0;
        try {
            List<Room> list = findAll();
            for (Room rom : list) {
                if (id.equals(rom.getRoomID())) {
                    c = find(id).getRoomType().getPrice();
                }
            }
        } catch (Exception ex) {
        }
        return c;
    }
}
